<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActionView::Helpers::TagHelper</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActionView::Helpers::TagHelper</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/rails/actionpack/lib/action_view/helpers/tag_helper_rb.html">
                vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Provides methods to generate HTML tags programmatically when you
can&#8216;t use a <a href="../../Builder.html">Builder</a>. By default,
they output XHTML compliant tags.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M002092">cdata_section</a>&nbsp;&nbsp;
      <a href="#M002091">content_tag</a>&nbsp;&nbsp;
      <a href="#M002093">escape_once</a>&nbsp;&nbsp;
      <a href="#M002090">tag</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->
    <div id="includes">
      <h3 class="section-bar">Included Modules</h3>

      <div id="includes-list">
        <span class="include-name"><a href="../../ERB/Util.html">ERB::Util</a></span>
      </div>
    </div>

    <div id="section">


    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">BOOLEAN_ATTRIBUTES</td>
          <td>=</td>
          <td class="context-item-value">%w(disabled readonly multiple checked).to_set</td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">BLOCK_CALLED_FROM_ERB</td>
          <td>=</td>
          <td class="context-item-value">'defined? __in_erb_template'</td>
        </tr>
        </table>
      </div>
    </div>



      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M002092" class="method-detail">
        <a name="M002092"></a>

        <div class="method-heading">
          <a href="#M002092" class="method-signature">
          <span class="method-name">cdata_section</span><span class="method-args">(content)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a CDATA section with the given <tt>content</tt>. CDATA sections are
used to escape blocks of text containing characters which would otherwise
be recognized as markup. CDATA sections begin with the string
<tt>&lt;![CDATA[</tt> and end with (and may not contain) the string
<tt>]]&gt;</tt>.
</p>
<h4>Examples</h4>
<pre>
  cdata_section(&quot;&lt;hello world&gt;&quot;)
  # =&gt; &lt;![CDATA[&lt;hello world&gt;]]&gt;

  cdata_section(File.read(&quot;hello_world.txt&quot;))
  # =&gt; &lt;![CDATA[&lt;hello from a text file]]&gt;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002092-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002092-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb, line 94</span>
94:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cdata_section</span>(<span class="ruby-identifier">content</span>)
95:         <span class="ruby-node">&quot;&lt;![CDATA[#{content}]]&gt;&quot;</span>
96:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002091" class="method-detail">
        <a name="M002091"></a>

        <div class="method-heading">
          <a href="#M002091" class="method-signature">
          <span class="method-name">content_tag</span><span class="method-args">(name, content_or_options_with_block = nil, options = nil, escape = true, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns an HTML block <a href="TagHelper.html#M002090">tag</a> of type
<tt>name</tt> surrounding the <tt>content</tt>. Add HTML attributes by
passing an attributes hash to <tt>options</tt>. Instead of passing the
content as an argument, you can also use a block in which case, you pass
your <tt>options</tt> as the second parameter. Set escape to false to
disable attribute value escaping.
</p>
<h4>Options</h4>
<p>
The <tt>options</tt> hash is used with attributes with no value like
(<tt>disabled</tt> and <tt>readonly</tt>), which you can give a value of
true in the <tt>options</tt> hash. You can use symbols or strings for the
attribute names.
</p>
<h4>Examples</h4>
<pre>
  content_tag(:p, &quot;Hello world!&quot;)
   # =&gt; &lt;p&gt;Hello world!&lt;/p&gt;
  content_tag(:div, content_tag(:p, &quot;Hello world!&quot;), :class =&gt; &quot;strong&quot;)
   # =&gt; &lt;div class=&quot;strong&quot;&gt;&lt;p&gt;Hello world!&lt;/p&gt;&lt;/div&gt;
  content_tag(&quot;select&quot;, options, :multiple =&gt; true)
   # =&gt; &lt;select multiple=&quot;multiple&quot;&gt;...options...&lt;/select&gt;

  &lt;% content_tag :div, :class =&gt; &quot;strong&quot; do -%&gt;
    Hello world!
  &lt;% end -%&gt;
   # =&gt; &lt;div class=&quot;strong&quot;&gt;Hello world!&lt;/div&gt;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002091-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002091-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb, line 68</span>
68:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">content_tag</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">content_or_options_with_block</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">options</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">escape</span> = <span class="ruby-keyword kw">true</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
69:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
70:           <span class="ruby-identifier">options</span> = <span class="ruby-identifier">content_or_options_with_block</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">content_or_options_with_block</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
71:           <span class="ruby-identifier">content_tag</span> = <span class="ruby-identifier">content_tag_string</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">capture</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>), <span class="ruby-identifier">options</span>, <span class="ruby-identifier">escape</span>)
72: 
73:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_called_from_erb?</span>(<span class="ruby-identifier">block</span>)
74:             <span class="ruby-identifier">concat</span>(<span class="ruby-identifier">content_tag</span>)
75:           <span class="ruby-keyword kw">else</span>
76:             <span class="ruby-identifier">content_tag</span>
77:           <span class="ruby-keyword kw">end</span>
78:         <span class="ruby-keyword kw">else</span>
79:           <span class="ruby-identifier">content_tag_string</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">content_or_options_with_block</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">escape</span>)
80:         <span class="ruby-keyword kw">end</span>
81:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002093" class="method-detail">
        <a name="M002093"></a>

        <div class="method-heading">
          <a href="#M002093" class="method-signature">
          <span class="method-name">escape_once</span><span class="method-args">(html)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns an escaped version of <tt>html</tt> without affecting existing
escaped entities.
</p>
<h4>Examples</h4>
<pre>
  escape_once(&quot;1 &gt; 2 &amp;amp; 3&quot;)
  # =&gt; &quot;1 &amp;lt; 2 &amp;amp; 3&quot;

  escape_once(&quot;&amp;lt;&amp;lt; Accept &amp; Checkout&quot;)
  # =&gt; &quot;&amp;lt;&amp;lt; Accept &amp;amp; Checkout&quot;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002093-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002093-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb, line 106</span>
106:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">escape_once</span>(<span class="ruby-identifier">html</span>)
107:         <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">Multibyte</span>.<span class="ruby-identifier">clean</span>(<span class="ruby-identifier">html</span>.<span class="ruby-identifier">to_s</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/[\&quot;&gt;&lt;]|&amp;(?!([a-zA-Z]+|(#\d+));)/</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">special</span><span class="ruby-operator">|</span> <span class="ruby-constant">ERB</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span><span class="ruby-operator">::</span><span class="ruby-constant">HTML_ESCAPE</span>[<span class="ruby-identifier">special</span>] }
108:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002090" class="method-detail">
        <a name="M002090"></a>

        <div class="method-heading">
          <a href="#M002090" class="method-signature">
          <span class="method-name">tag</span><span class="method-args">(name, options = nil, open = false, escape = true)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns an empty HTML <a href="TagHelper.html#M002090">tag</a> of type
<tt>name</tt> which by default is XHTML compliant. Set <tt>open</tt> to
true to create an open <a href="TagHelper.html#M002090">tag</a> compatible
with HTML 4.0 and below. Add HTML attributes by passing an attributes hash
to <tt>options</tt>. Set <tt>escape</tt> to false to disable attribute
value escaping.
</p>
<h4>Options</h4>
<p>
The <tt>options</tt> hash is used with attributes with no value like
(<tt>disabled</tt> and <tt>readonly</tt>), which you can give a value of
true in the <tt>options</tt> hash. You can use symbols or strings for the
attribute names.
</p>
<h4>Examples</h4>
<pre>
  tag(&quot;br&quot;)
  # =&gt; &lt;br /&gt;

  tag(&quot;br&quot;, nil, true)
  # =&gt; &lt;br&gt;

  tag(&quot;input&quot;, { :type =&gt; 'text', :disabled =&gt; true })
  # =&gt; &lt;input type=&quot;text&quot; disabled=&quot;disabled&quot; /&gt;

  tag(&quot;img&quot;, { :src =&gt; &quot;open &amp; shut.png&quot; })
  # =&gt; &lt;img src=&quot;open &amp;amp; shut.png&quot; /&gt;

  tag(&quot;img&quot;, { :src =&gt; &quot;open &amp;amp; shut.png&quot; }, false, false)
  # =&gt; &lt;img src=&quot;open &amp;amp; shut.png&quot; /&gt;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002090-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002090-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb, line 41</span>
41:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tag</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">options</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">open</span> = <span class="ruby-keyword kw">false</span>, <span class="ruby-identifier">escape</span> = <span class="ruby-keyword kw">true</span>)
42:         <span class="ruby-node">&quot;&lt;#{name}#{tag_options(options, escape) if options}#{open ? &quot;&gt;&quot; : &quot; /&gt;&quot;}&quot;</span>
43:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>